package com.keepsport.keepsportapi.controller;

import com.keepsport.keepsportapi.config.SystemConfig;
import com.keepsport.keepsportapi.service.intf.UserPlanService;
import com.keepsport.keepsportapi.vo.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@CrossOrigin
@Api(tags = "用户参与的课程")
@RestController
@RequestMapping("/api/plan/")
public class UserPlanController {
    @Resource
    private UserPlanService service;
    @ApiOperation(value = "报名")
    @GetMapping("add.do")
    public R add(int cid,HttpServletRequest request){
        System.out.println(request.getIntHeader(SystemConfig.TOKEN_HEADER));
        return service.save(cid,request.getIntHeader(SystemConfig.TOKEN_HEADER));

    }
    @ApiOperation(value = "查看参与的课程")
    @GetMapping("all.do")
    public R select(HttpServletRequest request){
        return service.query(request.getIntHeader(SystemConfig.TOKEN_HEADER));
    }
}
